/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.dahg.project.controller.model.beans.impl;

import java.util.List;
import javax.ejb.Stateless;
import org.dahg.project.controller.model.Producto;
import org.dahg.project.controller.model.beans.AbstractBean;
import org.dahg.project.controller.model.services.local.ProductoService;

/**
 *
 * @author dahg
 */
@Stateless
public class ProductoServiceImpl extends AbstractBean<Producto> implements ProductoService{

    @Override
    protected Class<Producto> getClazz() {
        return Producto.class;
    }

    @Override
    public void remove(Producto obj) {
        String delete="delete from Producto p where p.id=:id";
        remove(delete, obj.getId());
    }

    @Override
    public List<Producto> getAll() {
        String consulta="select p from Producto p order by p.categoria.id asc";
        return getEntityManager().createQuery(consulta).getResultList();
    }
    
}
